<template>
  <el-row :gutter="40" class="panel-group">
    <el-col :xs="12" :sm="12" :lg="4" class="card-panel-col">
      <div class="card-panel" @click="handleTimedChartData('requirement')">
        <div class="card-panel-icon-wrapper icon-requirement">
          <svg-icon icon-class="requirement" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">需求统计</div>
          <label class="card-panel-num">{{ data.requirement }}</label>
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="4" class="card-panel-col">
      <div class="card-panel" @click="handleTimedChartData('module')">
        <div class="card-panel-icon-wrapper icon-module">
          <svg-icon icon-class="module" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">模块统计</div>
          <label class="card-panel-num">{{ data.module }}</label>
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="4" class="card-panel-col">
      <div class="card-panel" @click="handleTimedChartData('version')">
        <div class="card-panel-icon-wrapper icon-version">
          <svg-icon icon-class="version" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">版本统计</div>
          <label class="card-panel-num">{{ data.version }}</label>
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="4" class="card-panel-col">
      <div class="card-panel" @click="handleTimedChartData('job')">
        <div class="card-panel-icon-wrapper icon-job">
          <svg-icon icon-class="job" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">任务统计</div>
          <label class="card-panel-num">{{ data.job }}</label>
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="4" class="card-panel-col">
      <div class="card-panel" @click="handleTimedChartData('testcase')">
        <div class="card-panel-icon-wrapper icon-testcase">
          <svg-icon icon-class="testcase" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">用例统计</div>
          <label class="card-panel-num">{{ data.testcase }}</label>
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="4" class="card-panel-col">
      <div class="card-panel" @click="handleTimedChartData('bug')">
        <div class="card-panel-icon-wrapper icon-bug">
          <svg-icon icon-class="bug" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">缺陷统计</div>
          <label class="card-panel-num">{{ data.bug }}</label>
        </div>
      </div>
    </el-col>
  </el-row>
</template>

<script setup name="PanelGroup">
const emit = defineEmits(["handleTimedChartData"]);
const props = defineProps({
  data: {
    type: Object,
    default: {},
  },
});

function handleTimedChartData(type) {
  emit("handleTimedChartData", type);
}
</script>

<style lang="scss" scoped>
.panel-group {
  margin-top: 18px;

  .card-panel-col {
    margin-bottom: 32px;
  }

  .card-panel {
    height: 108px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.1);

    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }

      .icon-requirement {
        background: #40c9c6;
      }

      .icon-module {
        background: #36a3f7;
      }

      .icon-version {
        background: #078068;
      }

      .icon-job {
        background: #5172f4;
      }

      .icon-testcase {
        background: #7a05f0;
      }

      .icon-bug {
        background: #f4516c;
      }
    }

    .icon-requirement {
      color: #40c9c6;
    }

    .icon-module {
      color: #36a3f7;
    }

    .icon-version {
      color: #34a6bf;
    }

    .icon-job {
      color: #344bbf;
    }

    .icon-testcase {
      color: #0774fa;
    }

    .icon-bug {
      color: #f4516c;
    }

    .card-panel-icon-wrapper {
      float: left;
      margin: 14px 0 0 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

    .card-panel-icon {
      float: left;
      font-size: 48px;
    }

    .card-panel-description {
      float: right;
      font-weight: bold;
      margin: 26px;
      margin-left: 0px;

      .card-panel-text {
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 16px;
        margin-bottom: 12px;
      }

      .card-panel-num {
        font-size: 20px;
      }
    }
  }
}

@media (max-width: 550px) {
  .card-panel-description {
    display: none;
  }

  .card-panel-icon-wrapper {
    float: none !important;
    width: 100%;
    height: 100%;
    margin: 0 !important;

    .svg-icon {
      display: block;
      margin: 14px auto !important;
      float: none !important;
    }
  }
}
</style>
